/**
 * 
 */
package com.tvshows.front.factory;

import org.apache.log4j.Logger;
import org.eclipse.swt.widgets.Composite;

import com.tvshows.front.ui.dialog.DialogUI;
import com.tvshows.front.view.dialog.DialogAddFavoriteView;
import com.tvshows.front.view.dialog.DialogErrorView;
import com.tvshows.front.view.dialog.DialogLogView;
import com.tvshows.front.view.dialog.DialogOptionsView;

/**
 * @author tangi
 * <p>
 * Class that creates a dialog type
 * </p>
 */
public class DialogFactory
{

    /**
     * The dialog view to create
     */
    private static DialogUI dialogUI;

    /**
     * Creates a dialog according to several criterias
     * 
     * @param typeUI the {@link TypeUI}
     * @param parent the parent composite
     * @param style the style
     * @param width the width
     * @param height the height
     * @return a DialogView
     */
    public static DialogUI createDialogUI( TypeUI typeUI, Composite parent, int style, int width, int height )
    {

        switch ( typeUI )
        {

            case ADD_FAVORITE:
                dialogUI = new DialogAddFavoriteView( parent, style );
                break;
            case ERROR_VIEW:
                dialogUI = new DialogErrorView( parent, style );
                break;
            case OPTION_VIEW:
                dialogUI = new DialogOptionsView( parent, style );
                break;
            case LOG_VIEW:
                dialogUI = new DialogLogView( parent, style );
                break;
            default:
                Logger.getLogger( DialogFactory.class ).error( "La vue " + typeUI.name() + " n'a pas été trouvée" );
                break;
        }
        parent.setSize( dialogUI.getSize() );

        return dialogUI;
    }

}
